package com.lee.ssm.service.impl;

import com.lee.ssm.dao.IPermissionDao;
import com.lee.ssm.domain.Permission;
import com.lee.ssm.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("iPermissionService")
public class PermissionServiceImpl implements IPermissionService {
    @Autowired
    private IPermissionDao iPermissionDao;

    @Override
    public List<Permission> findAll() throws Exception {
        return iPermissionDao.findAll();
    }

    @Override
    public void save(Permission permission) throws Exception {
        iPermissionDao.save(permission);
    }

    @Override
    public Permission findById(String id) {
        return iPermissionDao.findById(id);
    }

    @Override
    public void deleteById(String id) throws Exception {
        iPermissionDao.deletePermissionToAllRoleById(id);
        iPermissionDao.deleteById(id);
    }

    @Override
    public List<Permission> findOtherPermissionByRoleId(String id) throws Exception {
        return iPermissionDao.findOtherPermissionByRoleId(id);
    }
}
